package com.j2ee.JDKProxy.salary;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class SalaryInterceptor implements InvocationHandler{

	private Object target ;
	private Logger logger ;
	private Security security ;
	private privilege privilege ;
	
	public SalaryInterceptor(Object target, Logger logger, Security security, privilege privilege) {
		this.target = target;
		this.logger = logger;
		this.security = security;
		this.privilege = privilege;
	}
	
	@Override
	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		this.logger.logging();
		this.security.security();
		if(this.privilege.getAccess().equals("admin")) {
			method.invoke(target, args) ;
		} else {
			System.out.println("没有权限");
		}
		return null;
	}
	
	

}
